﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 代理模式
{
    class Program
    {
        static void Main(string[] args)
        {
            //还是不太懂。。。
            Proxy proxy = new Proxy();
            proxy.Request();

            Console.WriteLine();
        }
    }

    //代理接口 -- Subject
    abstract class Subject {
        public abstract void Request();
    }

    //RealSubject类--真正实体
    class RealSubject : Subject {
        public override void Request()
        {
            Console.WriteLine("真正实体！");
        }
    }

    //代理类
    class Proxy : Subject {
        RealSubject realsubject;

        public override void Request()
        {
            if (realsubject == null) {
                realsubject = new RealSubject();
            }
            realsubject.Request();
        }
    }
}
